package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.dto.ReplyDTO;
import com.tianji.learning.query.ReplyPageQuery;
import com.tianji.learning.service.InteractionReplyService;
import com.tianji.learning.vo.ReplyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "回答或评论的相关接口")
@RestController
@RequestMapping("/replies")
@RequiredArgsConstructor
public class InteractionReplyController {

    private final InteractionReplyService replyService;

    @ApiOperation("新增回答或者评论")
    @PostMapping
    public void saveReply(@RequestBody @Validated ReplyDTO replyDTO) {
        replyService.saveReply(replyDTO);
    }

    @ApiOperation("分页查询回答或者评论列表-客户端")
    @GetMapping("page")
    public PageDTO<ReplyVO> queryReplyVoPage(ReplyPageQuery query) {
        return replyService.queryReplyVoPage(query);
    }
}
